function move(ball, bourn) {
    //每次执行前先清除上一次的定时器
    clearInterval(ball.inte);

    ball.inte = setInterval(function () {
        if (ball.offsetLeft == bourn) {
            clearInterval(ball.inte);
        } else {
            //当每次步长凑不到一个整数的时候
            var lis = (bourn - ball.offsetLeft) / 10;
            lis = (lis > 0) ? Math.ceil(lis) : Math.floor(lis);
            ball.style.left = ball.offsetLeft + lis + "px";
        }
    },40)
}




var ul1 = document.getElementsByClassName("imglist")[0];
var li15 = document.getElementsByClassName("li15");
var a = 0;
var b = 0;
for (var i = 0; i < li15.length; i++) {
    li15[i].index = i;
    li15[i].onmouseover = function () {
        a = this.index;
        b = this.index;
        for (var i = 0; i < li15.length; i++) {

            li15[i].className = "li15"
        }
        this.className = "li15 on"
        var bourn = a * -950;
        move(ul1, bourn)
    }
}
var banner = document.getElementsByClassName("lun")[0];
banner.onmouseover = function () {
    clearInterval(o);
}
banner.onmouseout = function () {
    p();
}
function p() {
    o = setInterval(function () {
        a++;
        b++;
        if (a > 5) {
            ul1.style.left = 0
            a = 1
        }
        if (b > 4) {
            b = 0
        }
        for (var i = 0; i < li15.length; i++) {
            li15[i].className = "li15"
        }
        li15[b].className = "li15 on"
        var bourn = a * -950;
        move(ul1, bourn)
    }, 3000)
}
p();












































var li1 = document.querySelectorAll(".li1");
var six7_1 = document.querySelectorAll(".six7_1");


for (var i = 0; i < li1.length; i++) {
    li1[i].index = i;
    li1[i].onmouseenter = function() {
        for (var i = 0; i < li1.length; i++) {
            li1[i].className = "li1";
            six7_1[i].className = "six7_1";
        }
        this.className = "li1 li2";
        six7_1[this.index].className = "six7_1 six7_11";
    }
}
var li3 = document.querySelectorAll(".li3");
var seven7_1 = document.querySelectorAll(".seven7_1");


for (var i = 0; i < li3.length; i++) {
    li3[i].index = i;
    li3[i].onmouseenter = function() {
        for (var i = 0; i < li3.length; i++) {
            li3[i].className = "li3";
            seven7_1[i].className = "seven7_1";
        }
        this.className = "li3 li4";
        seven7_1[this.index].className = "seven7_1 seven7_11";
    }
}
var li5 = document.querySelectorAll(".li5");
var eight_1 = document.querySelectorAll(".eight_1");


for (var i = 0; i < li5.length; i++) {
    li5[i].index = i;
    li5[i].onmouseenter = function() {
        for (var i = 0; i < li5.length; i++) {
            li5[i].className = "li5";
            eight_1[i].className = "eight_1";
        }
        this.className = "li5 li6";
        eight_1[this.index].className = "eight_1 eight_11";
    }
}


var li7 = document.querySelectorAll(".li7 ");
var nine7_1 = document.querySelectorAll(".nine7_1");


for (var i = 0; i < li7.length; i++) {
    li7[i].index = i;
    li7[i].onmouseenter = function() {
        for (var i = 0; i < li7.length; i++) {
            li7[i].className = "li7 ";
            nine7_1[i].className = "nine7_1";
        }
        this.className = "li7  li8";
        nine7_1[this.index].className = "nine7_1 nine7_11";
    }
}

var li9 = document.querySelectorAll(".li9 ");
var ten7_1 = document.querySelectorAll(".ten7_1");


for (var i = 0; i < li9.length; i++) {
    li9[i].index = i;
    li9[i].onmouseenter = function() {
        for (var i = 0; i < li9.length; i++) {
            li9[i].className = "li9";
            ten7_1[i].className = "ten7_1";
        }
        this.className = "li9 li10";
        ten7_1[this.index].className = "ten7_1 ten7_11";
    }
}
var five = document.getElementsByClassName("five")[0];
var six = document.getElementsByClassName("six")[0];
var seven = document.getElementsByClassName("seven ")[0];
var eight = document.getElementsByClassName("eight")[0];
var nine = document.getElementsByClassName("nine")[0];
var ten = document.getElementsByClassName("ten")[0];
var suishoug = document.getElementsByClassName("suishoug")[0];
var dsc = document.getElementsByClassName("erjidaohang")[0];

var louc = document.getElementsByClassName("louc");
var fave = document.getElementsByClassName("fave");


window.onscroll = function() {

    if (document.body.scrollTop >= six.offsetTop && document.body.scrollTop < six.offsetTop) {

        for (var i = 0; i < louc.length; i++) {
            louc[i].style.backgroundColor = "#A3A0A1";
        }
        console.log("131223");
        louc[0].style.backgroundColor = "#FC5F8D";
    } else if (document.body.scrollTop >= six.offsetTop && document.body.scrollTop < seven.offsetTop) {
        // console.log("123");
        // 排他思想
        for (var i = 0; i < louc.length; i++) {
            louc[i].style.backgroundColor = "#A3A0A1";
        }
        louc[1].style.backgroundColor = " #FC5F8D";
    } else if (document.body.scrollTop >= seven.offsetTop && document.body.scrollTop < eight.offsetTop) {
        // console.log("123");
        // 排他思想
        for (var i = 0; i < louc.length; i++) {
            louc[i].style.backgroundColor = "#A3A0A1";
        }
        louc[2].style.backgroundColor = "#FC5F8D";
    } else if (document.body.scrollTop >= eight.offsetTop && document.body.scrollTop < nine.offsetTop) {
        // console.log("123");
        // 排他思想
        for (var i = 0; i < louc.length; i++) {
            louc[i].style.backgroundColor = "#A3A0A1";
        }
        louc[3].style.backgroundColor = " #FC5F8D";
    } else if (document.body.scrollTop >= nine.offsetTop && document.body.scrollTop < ten.offsetTop) {
        // console.log("123");
        // 排他思想
        for (var i = 0; i < louc.length; i++) {
            louc[i].style.backgroundColor = "#A3A0A1";
        }
        louc[4].style.backgroundColor = " #FC5F8D";
    } else if (document.body.scrollTop >= ten.offsetTop && document.body.scrollTop < suishoug.offsetTop) {
        // console.log("123");
        // 排他思想
        for (var i = 0; i < louc.length; i++) {
            louc[i].style.backgroundColor = "#A3A0A1";
        }
        louc[5].style.backgroundColor = " #FC5F8D";
    } else if (document.body.scrollTop >= suishoug.offsetTop) {
        // console.log("123");
        // 排他思想
        for (var i = 0; i < louc.length; i++) {
            louc[i].style.backgroundColor = "#A3A0A1";
        }
        louc[6].style.backgroundColor = " #FC5F8D";
    }
}



for (var i = 0; i < louc.length; i++) {
    louc[i].index = i;

    louc[i].onclick = function() {


        document.body.scrollTop = fave[this.index].offsetTop;
    }

}
window.onload = function() {
    var pre = document.querySelector("#pre");
    var nex = document.querySelector("#nex");
    var imglis = document.querySelector("#imglis");
    var cut = document.querySelectorAll("#cut span");
    var index = 1;
    var len = 3;
    var animated = false;
    var timer;

    function animate(offset) {
        var left = parseInt(imglis.style.left) + offset;
        var time = 100;
        var interval = 10;
        var speed = offset / (time / interval);

        function go() { //位移动画效果
            animated = true;
            if ((speed > 0 && parseInt(imglis.style.left) < left) || (speed < 0 && parseInt(imglis.style.left) > left)) {
                imglis.style.left = parseInt(imglis.style.left) + speed + "px";
                setTimeout(go, interval);
            } else {
                imglis.style.left = left + "px";
                if (left > -1200) {
                    imglis.style.left = -1200 * len + "px";
                } else if (left < (-1200 * len)) {
                    imglis.style.left = "-1200px";
                }
                animated = false;
            }
        }
        go();
    }

    function showBtn() { //圆点按钮切换效果
        for (var i = 0; i < cut.length; i++) {
            if (cut[i].className == "on") {
                cut[i].className = "";
                break;
            }
        }
        cut[index - 1].className = "on";
    }
    for (var i = 0; i < cut.length; i++) {
        cut[i].onmouseover = function() {
            if (animated) {
                return;
            } else if (this.className == "on") {
                return;
            }
            var myIndex = parseInt(this.getAttribute("index")); //取到的index属性是字符串，所以转number;
            var offset = -1200 * (myIndex - index);
            animate(offset);
            index = myIndex;
            showBtn();
        }

        pre.onclick = function() {
            if (animated) {
                return;
            }
            if (index == 1) {
                index = 3;
            } else {
                index -= 1;
            }
            animate(1200);
            showBtn();
        }
        nex.onclick = function() {
            if (animated) {
                return;
            }
            if (index == 3) {
                index = 1;
            } else {
                index += 1;
            }
            animate(-1200);
            showBtn();
        }

        function play() { //自动播放
            timer = setInterval(function() {
                nex.onclick();
            }, 3000);
        }

        function stop() {
            clearTimeout(timer);
        }
        unb.onmouseover = stop;
        unb.onmouseout = play;
        play();
    }
}


$(".abc").click(function() {
    $(".pb").css({
        "display": "block"
    })
})


$(".pb-hd i").click(function() {
    $(".pb").css({
        "display": "none"
    })
})